package com.css.apps.base.common.action;

import com.css.core.model.IServiceResult;
import com.css.db.memcached.MemCachedFactory;
import com.css.util.Ajax;
import com.css.util.Messages;
import com.css.webbase.webwork.action.UserAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@SuppressWarnings("serial")
public class ClearCache extends UserAction {
    private static Log log = LogFactory.getLog(ClearCache.class);

    @Override
    protected String userGo() {
        try {
            MemCachedFactory.buildClient().flushAll();
            result = Ajax.JSONResult(IServiceResult.RESULT_OK, Messages.getString("systemMsg.success"));
            return SUCCESS;
        } catch (Exception ex) {
            String msg = Messages.getString("systemMsg.failed");
            log.error(ex.getMessage(), ex);
            setResult(Ajax.JSONResult(IServiceResult.RESULT_OK, msg));
            return ERROR;
        }
    }

}
